#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>
#include <math.h>
int yzc(int l)
{
	if (l < 10)
		return 1;
	else
		return 1 + yzc(l / 10);
}
int main()
{
	int n;
	scanf("%d", &n);
	int a[20];
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	int tmp;
	for (int i = 0; i < n - 1; i++)
		for (int j = i + 1; j < n; j++)
		{
			int q = yzc(a[i]) > yzc(a[j]) ? yzc(a[j]) : yzc(a[i]);
			int b = pow(10, yzc(a[i] / 10));
			int c = pow(10, yzc(a[j] / 10));
			while (q)
			{
				if (a[i] / b < a[j] / c)
				{
					tmp = a[i];
					a[i] = a[j];
					a[j] = tmp;
					break;
				}
				else if (a[i] / b > a[j] / c)
				{
					break;
				}
				else
				{
					q--;
					b /= 10;
					c /= 10;
					if (q == 0)
					{
						if (b > c)
						{
							if (a[i] % 10 < a[i] / pow(10, yzc(a[i] / 10)))
							{
								tmp = a[i];
								a[i] = a[j];
								a[j] = tmp;
								break;
							}
						}
						if (b < c)
						{
							if (a[j] % 10 > a[j] / pow(10, yzc(a[j] / 10)))
							{
								tmp = a[i];
								a[i] = a[j];
								a[j] = tmp;
								break;
							}
						}
					}
				}
			}
		}
	for (int i = 0; i < n; i++)
	{
		printf("%d", a[i]);
	}
	return 0;
}